{template header}

<script src="js/common.js" type="text/javascript"></script>

<div class="container">
	<h3 class="marginbot tab">
		<!--{if $a != 'index'}--><a href="{UC_ADMINSCRIPT}?m=restful&a=index" class="sgbtn">{lang restful_ls}</a><!--{else}--><a>{lang restful_ls}</a><!--{/if}-->
		<!--{if $a != 'ls'}--><a href="{UC_ADMINSCRIPT}?m=restful&a=ls" class="sgbtn">{lang restful_app_ls}</a><!--{else}--><a>{lang restful_app_ls}</a><!--{/if}-->
		<!--{if $a != 'add'}--><a href="{UC_ADMINSCRIPT}?m=restful&a=add" class="sgbtn">{lang restful_app_new}</a><!--{else}--><a>{lang restful_app_new}</a><!--{/if}-->
	</h3>
	<!--{if $a == 'ls'}-->

		<div class="mainbox">
			<!--{if $apilist}-->
				<form action="{UC_ADMINSCRIPT}?m=restful&a=ls" method="post">
					<input type="hidden" name="formhash" value="{FORMHASH}">
					<table class="datalist fixwidth">
						<tr>
							<th nowrap="nowrap"><input type="checkbox" name="chkall" id="chkall" onclick="checkall('delete[]')" class="checkbox" /><label for="chkall">{lang app_delete}</label></th>
							<th nowrap="nowrap">appid</th>
							<th nowrap="nowrap">{lang restful_app_name}</th>
						</tr>
						<!--{eval $i = 0;}-->
						<!--{loop $apilist $api}-->
							<tr>
								<td width="60"><input type="checkbox" name="delete[]" value="$api[appid]" class="checkbox" /></td>
								<td width="100">$api[appid]</td>
								<td><a href="{UC_ADMINSCRIPT}?m=restful&a=detail&appid=$api[appid]"><strong>$api[name]</strong></a></td>
							</tr>
							<!--{eval $i++}-->
						<!--{/loop}-->
						<tr class="nobg">
							<td colspan="9"><input type="submit" value="{lang submit}" class="btn" /></td>
						</tr>
					</table>
					<div class="margintop"></div>
				</form>
			<!--{else}-->
				<p class="empty">{lang list_empty}</p>
			<!--{/if}-->
		</div>
	<!--{elseif $a == 'add'}-->
		<div class="mainbox">
			<div id="custom">
				<form action="{UC_ADMINSCRIPT}?m=restful&a=add" method="post">
				<input type="hidden" name="formhash" value="{FORMHASH}">
					<table class="opt">
						<tr>
							<th colspan="2">{lang restful_app_name}:</th>
						</tr>
						<tr>
							<td><input type="text" class="txt" name="name" value="" /></td>
							<td></td>
						</tr>
					</table>
					<div class="opt"><input type="submit" name="submit" value=" {lang submit} " class="btn" /></div>
				</form>
			</div>
		</div>
	<!--{elseif $a == 'detail'}-->
		<!--{if $updated}-->
			<div class="correctmsg"><p>{lang update_succeed}</p></div>
		<!--{elseif $addapi}-->
			<div class="correctmsg"><p>{lang app_add_succeed}</p></div>
		<!--{/if}-->
		<div class="mainbox">
			<form action="{UC_ADMINSCRIPT}?m=restful&a=detail&appid=$api['appid']" method="post">
			<input type="hidden" name="formhash" value="{FORMHASH}">
				<table class="opt">
					<tr>
						<th colspan="2">appid: $api['appid']</th>
					</tr>
					<tr>
						<th colspan="2">secret: $api['secret']</th>
					</tr>
					<tr>
						<th colspan="2">{lang app_name}:</th>
					</tr>
					<tr>
						<td><input type="text" class="txt" name="name" value="$api['name']" /></td>
						<td></td>
					</tr>
					<tr>
						<th colspan="2">{lang restful_callback}:</th>
					</tr>
					<tr>
						<td><textarea class="area" name="callback">$api['callback']</textarea></td>
						<td valign="top">{lang restful_callback_comment}</td>
					</tr>
				</table>

				<table class="datalist fixwidth">
					<tr>
						<th nowrap="nowrap">{lang restful_available}</th>
						<th nowrap="nowrap">{lang restful_api_url}</th>
						<th nowrap="nowrap">{lang restful_api_limit}</th>
					</tr>
					<!--{loop $apis $m $actions}-->
					<!--{loop $actions $a}-->
					<tr>
						<td width="20"><input name="perm[/$m/$a]" type="checkbox" {if empty($api['perm']) || !empty($api['perm']['/'.$m.'/'.$a])} checked{/if} /></td>
						<td width="300">/$m/$a</td>
						<td><input name="freq[/$m/$a]" type="text" value="{eval echo $api['freq']['/'.$m.'/'.$a] ?? 0;}" style="width: 100px" /></td>
					</tr>
					<!--{/loop}-->
					<!--{/loop}-->
				</table>

				<div class="opt"><input type="submit" name="submit" value=" {lang submit} " class="btn" /></div>
			</form>
		</div>
	<!--{else}-->
		<div class="mainbox">
			<table class="datalist fixwidth">
				<tr>
					<th nowrap="nowrap">{lang restful_api_url}</th>
				</tr>
				<!--{loop $apis $m $actions}-->
				<tr>
					<td onclick="show('sub_$m', 'auto')">/$m</td>
				</tr>
				<tbody id="sub_$m" style="display: none">
				<!--{loop $actions $a}-->
				<tr>
					<td>&nbsp;&nbsp;/$m/$a</td>
				</tr>
				<!--{/loop}-->
				</tbody>
				<!--{/loop}-->
			</table>
			<div class="margintop"></div>
		</div>
	<!--{/if}-->
</div>

{template footer}